<div>0001</div>
<div>0002</div>
<div>0003</div>
<script>
    ;
    (function (window, undefined) {
        function init(el) {
            // this全等于实例化对象
            // 1、获取所有数据
            let els = document.querySelectorAll(el)
            // 2、遍历，将JS dom绑定到jq对象上
            for (let i = 0; i < els.length; i++) {
                // els[i]标签
                this[i] = els[i]
            }
            this.length = els.length
        }
        let jQuery = function (el) {
            return new init(el)
        }
        // 添加原型方法
        init.prototype = {
            css(cssAttr, cssVal) {
                for (let i = 0; i < this.length; i++) {
                    this[i].style[cssAttr] = cssVal
                }
                return this
            },
            ajax(options) {},
            attr(options) {},
            addClass(options) {},
        }

        // window.全局变量
        window.jQuery = window.$ = jQuery
    })(window)
    let jqObj = new $('div')
    console.log(jqObj);
    jqObj.css('color', 'green').css('background', '#000')
</script>